NAVNavbar
Logo
cURL php NodeJS Python cSharp

Live YouTube Subtitles Advanced


Live YouTube Subtitles provides real-time data on subtitles in the video you specify in the request. You will get data from the watching page containing subtitled text, its language, and duration in the video.

Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-dashboard

<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
try {
    // Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-dashboard
    $client = new RestClient($api_url, null, 'login', 'password');
} catch (RestClientException $e) {
    echo "n";
    print "HTTP code: {$e->getHttpCode()}n";
    print "Error code: {$e->getCode()}n";
    print "Message: {$e->getMessage()}n";
    print  $e->getTraceAsString();
    echo "n";
    exit();
}
$post_array = array();
// You can set only one task at a time
$post_array[] = array(
    "language_code" => "en",
    "location_code" => 2840,
    "video_id" => mb_convert_encoding("Y8Wu4rSNJms", "UTF-8")
);
try {
    // POST /v3/serp/youtube/video_subtitles/live/advanced
    // in addition to 'youtube' and 'video_subtitles' you can also set other search engine and type parameters
    // the full list of possible parameters is available in documentation
    $result = $client->post('/v3/serp/youtube/video_subtitles/live/advanced', $post_array);
    print_r($result);
    // do something with post result
} catch (RestClientException $e) {
    echo "n";
    print "HTTP code: {$e->getHttpCode()}n";
    print "Error code: {$e->getCode()}n";
    print "Message: {$e->getMessage()}n";
    print  $e->getTraceAsString();
    echo "n";
}
$client = null;
?>

The above command returns JSON structured like this:

{
  "version": "0.1.20220819",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "2.4625 sec.",
  "cost": 0.006,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "11151919-4426-0139-0000-0d5843758631",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "2.0523 sec.",
      "cost": 0.006,
      "result_count": 1,
      "path": [
        "v3",
        "serp",
        "youtube",
        "video_subtitles",
        "live",
        "advanced"
      ],
      "data": {
        "api": "serp",
        "function": "live",
        "se": "youtube",
        "se_type": "video_subtitles",
        "language_code": "en",
        "location_code": 2840,
        "video_id": "Y8Wu4rSNJms",
        "subtitles_language": "en",
        "subtitles_translate_language": "it",
        "device": "desktop",
        "os": "windows"
      },
      "result": [
        {
          "video_id": "Y8Wu4rSNJms",
          "se_domain": "youtube.com",
          "location_code": 2840,
          "language_code": "en",
          "check_url": "https://www.youtube.com/watch?v=Y8Wu4rSNJms",
          "datetime": "2022-11-15 17:19:04 +00:00",
          "spell": null,
          "refinement_chips": null,
          "item_types": [
            "youtube_subtitles"
          ],
          "unsupported_language": false,
          "translate_language": "it",
          "origin_language": "en",
          "category": "Autos & Vehicles",
          "subtitles_count": 31,
          "title": "How to set up BMW eDrive Modes in the New Generation of BMW Plug-In Hybrids",
          "items_count": 31,
          "items": [
            {
              "type": "youtube_subtitles",
              "rank_group": 1,
              "rank_absolute": 1,
              "text": "elettrizza la tua efficienza di guida",
              "start_time": 1.12,
              "end_time": 6,
              "duration_time": 4.88
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 2,
              "rank_absolute": 2,
              "text": "la trazione ibrida plug-in nelle BMW con",
              "start_time": 3.679,
              "end_time": 8.48,
              "duration_time": 4.801
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 3,
              "rank_absolute": 3,
              "text": "sistema operativo 8 ti offre il",
              "start_time": 6,
              "end_time": 10.72,
              "duration_time": 4.719
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 4,
              "rank_absolute": 4,
              "text": "controllo individuale per passare dalla trazione completamente elettrica alla",
              "start_time": 8.48,
              "end_time": 13.36,
              "duration_time": 4.88
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 5,
              "rank_absolute": 5,
              "text": "trazione combinata del motore",
              "start_time": 10.719,
              "end_time": 15.6,
              "duration_time": 4.88
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 6,
              "rank_absolute": 6,
              "text": "premi il pulsante delle impostazioni di guida nella",
              "start_time": 13.36,
              "end_time": 17.68,
              "duration_time": 4.32
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 7,
              "rank_absolute": 7,
              "text": "console centrale",
              "start_time": 15.599,
              "end_time": 19.76,
              "duration_time": 4.161
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 8,
              "rank_absolute": 8,
              "text": "sotto la trasmissione e il telaio puoi",
              "start_time": 17.68,
              "end_time": 23.04,
              "duration_time": 5.359
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 9,
              "rank_absolute": 9,
              "text": "attivare rapidamente la trazione elettrica  modalità in",
              "start_time": 19.76,
              "end_time": 25.04,
              "duration_time": 5.279
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 10,
              "rank_absolute": 10,
              "text": "alternativa apri le",
              "start_time": 23.039,
              "end_time": 27.2,
              "duration_time": 4.16
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 11,
              "rank_absolute": 11,
              "text": "impostazioni di trasmissione e telaio dove puoi anche",
              "start_time": 25.039,
              "end_time": 29.44,
              "duration_time": 4.4
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 12,
              "rank_absolute": 12,
              "text": "avviare o arrestare la modalità di guida elettrica,",
              "start_time": 27.199,
              "end_time": 31.12,
              "duration_time": 3.92
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 13,
              "rank_absolute": 13,
              "text": "nonché attivare l'elettrico",
              "start_time": 29.439,
              "end_time": 33.36,
              "duration_time": 3.921
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 14,
              "rank_absolute": 14,
              "text": "automaticamente impostando in elettrico",
              "start_time": 31.119,
              "end_time": 35.76,
              "duration_time": 4.641
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 15,
              "rank_absolute": 15,
              "text": "automaticamente la tua bmw si avvierà in",
              "start_time": 33.36,
              "end_time": 37.76,
              "duration_time": 4.4
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 16,
              "rank_absolute": 16,
              "text": "modalità elettrica se la carica della batteria è",
              "start_time": 35.76,
              "end_time": 40.64,
              "duration_time": 4.88
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 17,
              "rank_absolute": 17,
              "text": "abbastanza alta generalmente la tua bmw regola",
              "start_time": 37.76,
              "end_time": 43.04,
              "duration_time": 5.28
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 18,
              "rank_absolute": 18,
              "text": "la spina  -nella guida ibrida in modo intelligente",
              "start_time": 40.64,
              "end_time": 45.28,
              "duration_time": 4.64
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 19,
              "rank_absolute": 19,
              "text": "fintanto che non guidi in modo troppo sportivo o",
              "start_time": 43.04,
              "end_time": 47.68,
              "duration_time": 4.64
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 20,
              "rank_absolute": 20,
              "text": "troppo veloce e la batteria è sufficientemente",
              "start_time": 45.28,
              "end_time": 49.76,
              "duration_time": 4.48
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 21,
              "rank_absolute": 21,
              "text": "carica la tua bmw rimarrà in",
              "start_time": 47.68,
              "end_time": 52.08,
              "duration_time": 4.399
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 22,
              "rank_absolute": 22,
              "text": "modalità elettrica nelle",
              "start_time": 49.76,
              "end_time": 54.64,
              "duration_time": 4.88
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 23,
              "rank_absolute": 23,
              "text": "impostazioni di trasmissione e telaio puoi anche attivare",
              "start_time": 52.079,
              "end_time": 56.88,
              "duration_time": 4.8
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 24,
              "rank_absolute": 24,
              "text": "mantenere la carica della batteria per risparmiare la",
              "start_time": 54.64,
              "end_time": 58.32,
              "duration_time": 3.68
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 25,
              "rank_absolute": 25,
              "text": "corrente  stato di carica della",
              "start_time": 56.879,
              "end_time": 60.32,
              "duration_time": 3.441
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 26,
              "rank_absolute": 26,
              "text": "batteria ad alta tensione per un punto successivo del",
              "start_time": 58.32,
              "end_time": 62.16,
              "duration_time": 3.84
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 27,
              "rank_absolute": 27,
              "text": "viaggio",
              "start_time": 60.32,
              "end_time": 64.24,
              "duration_time": 3.919
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 28,
              "rank_absolute": 28,
              "text": "con  continua a guardare la nostra serie di istruzioni per",
              "start_time": 62.16,
              "end_time": 68.36,
              "duration_time": 6.2
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 29,
              "rank_absolute": 29,
              "text": "ottenere il massimo dalla tua bmw",
              "start_time": 64.239,
              "end_time": 68.36,
              "duration_time": 4.121
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 30,
              "rank_absolute": 30,
              "text": "[Musica].",
              "start_time": 69.33,
              "end_time": 75.12,
              "duration_time": 5.789
            },
            {
              "type": "youtube_subtitles",
              "rank_group": 31,
              "rank_absolute": 31,
              "text": "",
              "start_time": 73.04,
              "end_time": 75.12,
              "duration_time": 2.079
            }
          ]
        }
      ]
    }
  ]
}

All POST data should be sent in the JSON format (UTF-8 encoding). When setting a task, you should send all task parameters in the task array of the generic POST array. You can send up to 2000 API calls per minute, each Live SERP API call can contain only one task.

Below you will find a detailed description of the fields you can use for setting a task.

Description of the fields for setting a task:

Field name Type Description
video_id string ID of the video
required field
you can find video ID in the URL or ‘youtube_video’ item of YouTube Organic result
example:
Y8Wu4rSNJms
subtitles_language string language code of original text
you can get the language code from YouTube Video Info result
subtitles_translate_language string language code of translated text
possible values:
"az", "ay", "ak", "sq", "am", "en", "ar", "hy", "as", "af", "eu", "be", "bn", "my", "bg", "bs", "bho", "cy", "hu", "vi", "haw", "ht", "gl", "lg", "el", "ka", "gn", "gu", "gd", "da", "fy", "zu", "iw", "ig", "yi", "id", "ga", "is", "es", "it", "yo", "kk", "kn", "ca", "qu", "rw", "ky", "zh-Hant", "zh-Hans", "ko", "co", "xh", "ku", "km", "lo", "la", "lv", "ln", "lt", "lb", "mk", "mg", "ms", "ml", "dv", "mt", "mi", "mr", "mn", "und", "de", "ne", "nl", "no", "ny", "or", "om", "pa", "fa", "pl", "pt", "ps", "ro", "ru", "sm", "sa", "ceb", "nso", "sr", "si", "sd", "sk", "sl", "so", "sw", "su", "tg", "th", "ta", "tt", "te", "ti", "ts", "tr", "tk", "uz", "ug", "uk", "ur", "fil", "fi", "fr", "ha", "hi", "hmn", "hr", "cs", "sv", "sn", "ee", "eo", "et", "st", "jv", "ja", "kri"
location_name string full name of search engine location
required field if you don’t specify location_code
if you use this field, you don’t need to specify location_code
you can receive the list of available locations of the search engine with their location_name by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/locations
example:
United States
location_code integer search engine location code
required field if you don’t specify location_name 
if you use this field, you don’t need to specify location_name
you can receive the list of available locations of the search engines with their location_code by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/locations
example:
2840
language_name string full name of search engine language
required field if you don’t specify language_code
if you use this field, you don’t need to specify language_code
you can receive the list of available languages of the search engine with their language_name by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/languages
example:
English
language_code string search engine language code
required field if you don’t specify language_name
if you use this field, you don’t need to specify language_name
you can receive the list of available languages of the search engine with their language_code by making a separate request to the https://api.dataforseo.com/v3/serp/youtube/languages
example:
en
device string device type
optional field
only value: desktop
os string device operating system
optional field
choose from the following values: windows, macos
default value: windows
tag string user-defined task identifier
optional field
the character limit is 255
you can use this parameter to identify the task and match it with the result
you will find the specified tag value in the data object of the response

‌‌‌
As a response of the API server, you will receive JSON-encoded data containing a tasks array with the information specific to the set tasks.

Description of the fields in the results array:

Field name Type Description
version string the current version of the API
status_code integer general status code
you can find the full list of the response codes here
Note: we strongly recommend designing a necessary system for handling related exceptional or error conditions
status_message string general informational message
you can find the full list of general informational messages here
time string execution time, seconds
cost float total tasks cost, USD
tasks_count integer the number of tasks in the tasks array
tasks_error integer the number of tasks in the tasks array returned with an error
tasks array array of tasks
        id string task identifier
unique task identifier in our system in the UUID format
        status_code integer status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
you can find the full list of the response codes here
        status_message string informational message of the task
you can find the full list of general informational messages here
        time string execution time, seconds
        cost float cost of the task, USD
        result_count integer number of elements in the result array
        path array URL path
        data object contains the same parameters that you specified in the POST request
        result array array of results
            video_id string ID of the video received in a POST array
            se_domain string search engine domain in a POST array
            location_code integer location code in a POST array
            language_code string language code in a POST array
            check_url string direct URL to search engine results
you can use it to make sure that we provided accurate results
            datetime string date and time when the result was received
in the UTC format: “yyyy-mm-dd hh-mm-ss +00:00”
example:
2019-11-15 12:57:46 +00:00
            spell object autocorrection of the search engine
if the search engine provided results for a keyword that was corrected, we will specify the keyword corrected by the search engine and the type of autocorrection
            refinement_chips object search refinement chips
equals null
            item_types array types of search results in SERP
contains types of search results (items) found in SERP.
possible item:
youtube_subtitles
            unsupported_language boolean indicates whether the language is unsupported by the system
            translate_language string language code of translated text
            origin_language string language code of original text
            category string the category the video belongs to
            subtitles_count integer number of subtitles in the video
            title string title of the video
            items_count integer the number of results returned in the items array
            items array elements of search results found in SERP
                type string type of element = ‘youtube_subtitles’
                rank_group integer group rank in SERP
position within a group of elements with identical type values
positions of elements with different type values are omitted from rank_group
                rank_absolute integer absolute rank in SERP for the target domain
absolute position among all the elements in SERP
                text string text translated in subtitles
                start_time integer the second subtitled text starts
                end_time integer the second subtitled text ends
                duration_time integer duration of subtitles in seconds

‌‌